<extend name="Common@Layout:base" />
<block name="title">
    <title>{:L('我的主页')}</title>
</block>
<block name="style">
    <style type="text/css">
        #artic-page {
            /*margin-bottom: 100px;*/
        }
        
        .jie-row li .jie-title {
            width: 200px;
        }
        
        .jie-row li a {
            padding: 0px;
        }
        
        .home-jieda li a span {
            margin: 0px;
            max-width: 200px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</block>

<block name="main">
    <include file="Common@Include:header" />

    <div class="main fly-user-main layui-clear">
        <php>$curMenu = 6;</php>
        <include file="Include:menu" />

        <div class="site-tree-mobile layui-hide">
            <i class="layui-icon"></i>
        </div>
        <div class="site-mobile-shade"></div>
        <div class="fly-panel fly-panel-user" pad20="" style="background: none;margin-right:215px;padding:0;">

            <div class="main fly-home-main" style="width: 900px;height: 690px;">
                <div class="layui-inline fly-home-jie" style="width:445px;height: 690px;">
                    <div class="fly-panel" style="height: 690px;">

                        <div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_uc" style="margin: 0;">

                            <ul class="layui-tab-title fly-panel-title">
                                <!--<li lay-id="mycontents" class="layui-this">我的文章</li>-->
                               
                               <li lay-id="mycontents" class="layui-this">标题1</li>
                            </ul>

                            <div class="layui-tab-content" style="padding: 20px 0;">

                                <div class="layui-tab-item layui-show">
                                    <!--<ul class="jie-row" id="artic">
                                    </ul>-->
									
								待开发。。。
                                    <div id="artic-page" style="text-align: center;"></div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
        </div>


    </div>
    <include file="Common@Include:footer" />
</block>

<block name="script">
    <script type="text/javascript">
        layui.use(['layer', 'jquery', 'laypage', 'laytpl', 'form', 'face'], function() {
            var $ = layui.jquery,
                layer = layui.layer,
                laytpl = layui.laytpl,
                laypage = layui.laypage,
                faces = layui.face,
                form = layui.form;

//			var $datacon = $('#artic');
//					getartic(1,10);
//					function getartic(p,row){
//						var dataUrl = '/User/Mynotes/get_artic';
//						var myCondition = "p=" + p + "&row=" + row;
//						var $pageDom = $('#artic-page');
//						var dataTpl = $('#artic-tpl').html();
//			//			console.log(dataTpl);
//				        $.ajax({
//							url: dataUrl,
//				            cache: true, //缓存数据
//				            type: "POST",
//				            data: myCondition,
//				            dataType: "json",
//				            beforeSend: function() {
//				                ii = layer.msg('Loading...', { icon: 16, time: 10000 });
//				            },
//				            complete: function() {
//				                layer.close(ii);
//				            },
//				            success: function(res) {
//				                if (res.status) {
//				                    //开始渲染数据
//			//						console.log(res);
//				                    var data = res.data.data;
//				                    if(data){
//				                        for(var i=0; i<data.length; i++){
//				                            data[i].content = changeContent(data[i].content);
//			//	                            data[i].update_time = setTime(data[i].update_time);
//				                        }
//				                    }
//				                    laytpl(dataTpl).render(data, function(html) {
//				                        $datacon.html(html);
//				                        listen_aite();
//				                    });
//				                    //载入分页
//				                    if ($pageDom.length != 0) {
//				                        laypage({
//				                            cont: $pageDom,
//				                            pages: Math.ceil(res.data.page.total / res.data.page.row),
//				                            first: 1,
//				                            last: Math.ceil(res.data.page.total / res.data.page.row),
//				                            curr: res.data.page.cur,
//				                            prev: '上一页',
//				                            next: '下一页',
//				                            skip: true,
//				                            jump: function(obj) {
//				                                //处理跳转，回调自己（递归）
//				                                if (obj.curr != p) {
//				                                    p = obj.curr;
//				                                    //当前页发生改变的时候执行一下改变
//				                                    $datacon.attr('data-p', p);
//				                                    $datacon.attr('data-row', row);
//				
//				                                    getartic(p,row);
//				                                }
//				
//				                            }
//				                        });
//				                    }
//				
//				                } else {
//				                    layer.msg(res.info, { icon: 2, time: 1000 });
//				                }
//				            }
//				        });
//					}


            function changeContent(content) {
                //支持的html标签
                var html = function(end) {
                    return new RegExp('\\[' + (end || '') + '(pre|div|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)\\]\\n*', 'g');
                };
                content = escape(content || '') //XSS
                    .replace(/img\[([^\s]+?)\]/g, function(img) { //转义图片
                        return '<img data-isbig="0" class="lxd-img" width="200px" src="' + img.replace(/(^img\[)|(\]$)/g, '') + '">';
                    }).replace(/@(\S+)(\s+?|$)/g, '@<a href="javascript:;" class="fly-aite">$1</a>$2') //转义@
                    .replace(/face\[([^\s\[\]]+?)\]/g, function(face) { //转义表情
                        var alt = face.replace(/^face/g, '');
                        return '<img alt="' + alt + '" title="' + alt + '" src="' + faces[alt] + '">';
                    }).replace(/a\([\s\S]+?\)\[[\s\S]*?\]/g, function(str) { //转义链接
                        var href = (str.match(/a\(([\s\S]+?)\)\[/) || [])[1];
                        var text = (str.match(/\)\[([\s\S]*?)\]/) || [])[1];
                        if (!href) return str;
                        var rel = /^(http(s)*:\/\/)\b(?!(\w+\.)*(sentsin.com|layui.com))\b/.test(href.replace(/\s/g, ''));
                        return '<a href="' + href + '" target="_blank"' + (rel ? ' rel="nofollow"' : '') + '>' + (text || href) + '</a>';
                    }).replace(html(), '\<$1\>').replace(html('/'), '\</$1\>') //转移代码
                    .replace(/\n/g, '<br>') //转义换行   
                return content;
            }

            function escape(html) {
                return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
                    .replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
            }

            function listen_aite() {
                $('.fly-aite').unbind('click').click(function() {
                    var name = $(this).html();
                    var uid = '';
                    $.get("/User/Mynotes/get_uid", {
                        name: name
                    }, function(result) {
                        if (result.status) {
                            uid = result.data;
                            window.open("/user/userinfo/index.html?uid=" + uid);
                        }
                    });


                });
            }

            function setTime(time) {
                var currentTime = Date.parse(new Date());
                var dateTime = time; //后台传递来的时间
                var ts = ''; //选择器
                var d_day = Date.parse(new Date(dateTime));
                var day = Math.abs(parseInt((d_day - currentTime) / 1000 / 3600 / 24)); //计算日期
                var hour = Math.abs(parseInt((d_day - currentTime) / 1000 / 3600)); //计算小时
                var minutes = Math.abs(parseInt((d_day - currentTime) / 1000 / 60)); //计算分钟
                var seconds = Math.abs(parseInt((d_day - currentTime) / 1000)); //计算秒
                if (day >= 2) {
                    ts = (parseInt(day) + "天前").toString();
                } else if (day > 0 && day < 2) {
                    ts = ("昨天").toString();
                } else if (hour > 0 && hour < 24) {
                    ts = (parseInt(hour) + "小时前").toString();
                } else if (minutes > 0 && minutes < 60) {
                    ts = (parseInt(minutes) + "分钟前").toString();
                } else if (seconds > 0 && seconds < 60) {
                    ts = (parseInt(seconds) + "秒前").toString();
                }
                return ts;
            }

        });

        function userinfo(uid) {
            window.open("/user/userinfo/index.html?uid=" + uid);
        }
    </script>

</block>